// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    categories: [
      {
        id: "new",
        icon: "../../images/icon/new.png",
        name: "新房"
      },
      {
        id: "second",
        icon: "../../images/icon/second.png",
        name: "二手房"
      },
      {
        id: "third",
        icon: "../../images/icon/office.jpg",
        name: "商办"
      },
      {
        id: "forth",
        icon: "../../images/icon/borrow.png",
        name: "租赁"
      }
    ],
    recommends: {
      新房: [],
      二手房: [],
      商办: [],
      租赁: []
    }
  },
  // 事件处理函数
  bindViewTap() {

  },
  onLoad() {
    let test_data = [{
      id: "1",
      price: "61.6万",
      locale: "平凉市 崆峒区 广成花园B区",
      tags: ["满五年", "红本在手","升值潜力"],
      title: "房东急售",
      img: "https://www.robbeykaaso.work:3000/assets/images/system.png"
    },
    {
      id: "2",
      price: "67.0万",
      locale: "平凉市 崆峒区 定北路172号",
      tags: ["满五年"],
      title: "暖泉小区2室2厅1卫",
      img: "https://www.robbeykaaso.work:3000/assets/images/format.png"
    },
    {
      id: "3",
      price: "36.0万",
      locale: "平凉市 崆峒区 果园路90号",
      title: "果园路小区2室1厅1卫 急用钱",
      img: "https://www.robbeykaaso.work:3000/assets/images/editting.png"
    }]
    for (let i in this.data.recommends)
      this.data.recommends[i] = test_data
    this.initBanners()
    //console.log(this.data.recommends)
    this.setData({recommends: this.data.recommends})
  },
  getUserProfile(e) {

  },
  initBanners(){
    const _data = {}
    /*// 读取头部轮播图
    const res1 = await WXAPI.banners({
      type: 'index'
    })
    if (res1.code == 700) {
      wx.showModal({
        title: '提示',
        content: '请在后台添加 banner 轮播图片，自定义类型填写 index',
        showCancel: false
      })
    } else {
      _data.banners = res1.data
    }*/
    _data.banners = [
      { id: "first", 
        linkUrl: "",
        picUrl: "https://www.robbeykaaso.work:3000/assets/images/services.jpg"
      },
      { id: "second",
        linkUrl: "",
        picUrl: "https://www.robbeykaaso.work:3000/assets/images/visualization.png"
      },
      { id: "third",
        linkUrl: "",
        picUrl: "https://www.robbeykaaso.work:3000/assets/images/storage.png"
      }
    ]
    this.setData(_data)
  },
  getUserInfo(e) {

  }
})
